#include <iostream>
#include <string>

#include "media/video.h"  // 使用video.h头文件有冲突
#include "media/error.h"
#include "h264decoder.h"


int main() {
    VideoReader reader;
    std::string file("../tqzz.mp4");    
    int ret = reader.Init(file);
    if(ret != MM_OK) {
        fprintf(stderr, "VideoReader init failed %d\n", ret);
        return -1;
    }

    H264Decoder decoder;
    while (true){
        uint8_t buf[4096*2]={"\0"};
        int size = 4096*2;
        ret = reader.GetPacket(buf, &size);
        if(ret != MM_OK) {
            fprintf(stderr, "VideoReader GetPacket failed %d\n", ret);
            return -1;
        }

        ret = decoder.DecodePacket(buf, size, 0,1);
        if(decoder.IsKeyFrame()) {
            break;
        }
    }

    return 0;
}